/**
 *  \brerf 
 *  \author pengcheng(pengcheng@adcsoft.cn)
 *  \date 2019.11.25
 *  \attention 
 * 
 */

#include "cmw_app/time_adcsoft.h"

namespace adc
{

Timer::Timer(const float& hz): 
               duration_ {std::chrono::duration<float>(1.0 / hz)},
               start_ {},
               elapsed_ {}
{

}

void Timer::Start()
{
    start_ = std::chrono::system_clock::now();
}

void Timer::Stop()
{
    elapsed_ = std::chrono::system_clock::now() - start_;

    if( elapsed_ < duration_)
    {
        std::this_thread::sleep_for(duration_ - elapsed_);
    }
}

}